#include "widget.h"
#include "ui_widget.h"

#include <QTimer>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

//    ui->lcdNumber->display("10");
    ui->lcdNumber->display(10);
    timer = new QTimer(this);
    connect(timer, &QTimer::timeout, this, &Widget::handler);
    timer->start(1000);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handler()
{
    int val = ui->lcdNumber->value();
    if(val <= 0){
        timer->stop();
        return;
    }
    ui->lcdNumber->display(val - 1);
}

